<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>我的微博页面</h1>
<div>
    <div v-for="weibo in arr">
        <h3>{{weibo.title}}<a href="javascript:void (0)" @click="del(weibo.id)"></a></h3>
        <p>{{weibo.content}}</p>
        <img :src="weibo.url" style="width: 200px" alt="">

    </div>
</div>
<!--引入axios和vue-->
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script>
    let v = new Vue({
        el:"body>div",
        data:{
            arr:[]
        },
        created:function () {
            axios.get("/weibo/select/my").then(function (response) {
                if(response.data.status==2){
                    alert("请先登录");
                    location.href = "login.html";
                    return;
                }
                v.arr = response.data.content;
            })
        },
        methods:{
            del:function (id) {
                if(confirm("您确定要删除这条微博吗?")){
                    axios.get("/weibo/delete?id="+id).then(function () {
                        location.reload();//刷新页面
                    })
                }
            }
        }
    })
</script>
</body>
</html>